package android.framework.binding;

import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;

public class StringViewBindingHandler extends ViewBindingHandler<String> implements TextWatcher, OnItemSelectedListener{

	public void afterTextChanged(Editable s) {
		
	}

	public void beforeTextChanged(CharSequence s, int start, int count,
			int after) {
	}

	public void onTextChanged(CharSequence s, int start, int before, int count) {
		String newText = s.toString();
		if(lastValue == null || !lastValue.equals(newText)){
			lastValue = newText;
			notifyListener(newText);
		}	
	}

	public void onItemSelected(AdapterView<?> parent, View view, int position,
			long id) {
		String newText = parent.getItemAtPosition(position).toString();
		if(lastValue == null || !lastValue.equals(newText)){
			lastValue = newText;
			notifyListener(newText);
		}	
	}

	public void onNothingSelected(AdapterView<?> arg0) {
		
	}

	



}
